<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>
	//1.直接绑定事件
	function f1(e) {
		console.log(1);
		console.log(e);
	}
	//2.后绑定事件
	//页面加载后
	window.onload = function() {
		//获取按钮2
		var btn = document.getElementById("btn2");
		//给它绑定单击事件
		btn.onclick = function(e){
			console.log(2);
			console.log(e);
		}
	}
</script>
</head>
<body>
	<input type="button" value="按钮1"
		onclick="f1(event);"/>
	<input type="button" value="按钮2"
		id="btn2"/>
</body>
</html>







